<!--
 * @Author: Penk
 * @LastEditors: Penk
 * @LastEditTime: 2021-04-23 14:16:13
 * @FilePath: \test_html\crawler\index.html
-->
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    * {
      margin: 0;
      padding: 0;
    }

    body {
      margin: 20px;
    }

    .inputBox {}

    .inputBox .urlSpan {}

    .inputBox #urlInput {
      width: 200px;
    }

    .contentBox {
      margin-top: 20px;
    }

    .contentBox .sku {
      margin-top: 20px;
    }

    .contentBox .sku .skuSpan {
      vertical-align: top;
    }

    .contentBox .sku .showSku {
      display: inline-block;
      margin-left: 20px;
    }
  </style>
</head>

<body>
  <div class="inputBox">
    <span class="urlSpan">请输入URL：</span>
    <input id="urlInput" type="text" onblur="getInfo();"
      value="https://mobile.yangkeduo.com/goods.html?goods_id=33247622726&_oak_rem_ar_id=999&_oak_gallery=http%3A%2F%2Ft00img.yangkeduo.com%2Fgoods%2Fimages%2F2021-04-19%2F03454318919eb3d8876c394a27c2b428.jpeg&page_from=35&refer_page_name=index&refer_page_id=10002_1619158555342_p1eozmon6s&refer_page_sn=10002" />
    <!-- <input id="urlInput" type="text" onblur="getInfo();" value="https://back.yueyueniao.cn/#/login" /> -->
  </div>
  <div class="contentBox">
    <!-- 展示价格 -->
    <div class="price">
      <span class="price">转换后价格：</span>
      <span class="showPrice"></span>
    </div>
    <!-- 展示SKU -->
    <div class="sku">
      <span class="skuSpan">Sku：</span>
      <span class="showSku"></span>
      <br>
    </div>
  </div>

  <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
  <script>
    let urlInput = document.querySelector('#urlInput');
    let showPrice = document.querySelector('.showPrice');
    let showSku = document.querySelector('.showSku');

    function sum(val) {
      return parseInt((parseInt(val) + 13) * 1.54 * 4.5);
    }

    function getInfo() {
      // 特殊字符转义
      let tempUrl = urlInput.value.replace(/&/g, 'zyp');
      console.log(tempUrl);
      axios.get('/getInfo?url=' + tempUrl)
        .then(function (response) {
        })
        .catch(function (error) {
        });
      // 设置转换价格
      let price = 1;
      showPrice.textContent = sum(price);

      // 设置SKU
      let sku = '<h1>测试</h1><h1>测试</h1><h1>测试</h1><h1>测试</h1>';
      showSku.innerHTML = sku;
    }

    getInfo();
  </script>
</body>

</html>